{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>.container { width:100% !important; }</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>RU</th>\n",
       "      <th>MA</th>\n",
       "      <th>V</th>\n",
       "      <th>L</th>\n",
       "      <th>PP</th>\n",
       "      <th>BU</th>\n",
       "      <th>TA</th>\n",
       "      <th>商品板块</th>\n",
       "      <th>工业品</th>\n",
       "      <th>化工板块</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20190920</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-799167600</td>\n",
       "      <td>22839180</td>\n",
       "      <td>0</td>\n",
       "      <td>498086400</td>\n",
       "      <td>225910000</td>\n",
       "      <td>-127382530</td>\n",
       "      <td>-551954295</td>\n",
       "      <td>-3367909283</td>\n",
       "      <td>-2090441051</td>\n",
       "      <td>-731668845</td>\n",
       "      <td>L</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190923</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-857010960</td>\n",
       "      <td>165942600</td>\n",
       "      <td>0</td>\n",
       "      <td>654374000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>508981530</td>\n",
       "      <td>902773365</td>\n",
       "      <td>-243088285</td>\n",
       "      <td>472287170</td>\n",
       "      <td>L</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190924</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-967891680</td>\n",
       "      <td>163540080</td>\n",
       "      <td>0</td>\n",
       "      <td>391617030</td>\n",
       "      <td>0</td>\n",
       "      <td>148707000</td>\n",
       "      <td>-65240430</td>\n",
       "      <td>-3829352983</td>\n",
       "      <td>-2584954486</td>\n",
       "      <td>-329268000</td>\n",
       "      <td>L</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190925</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-1042963470</td>\n",
       "      <td>159498430</td>\n",
       "      <td>0</td>\n",
       "      <td>309569320</td>\n",
       "      <td>330986565</td>\n",
       "      <td>303896740</td>\n",
       "      <td>501787305</td>\n",
       "      <td>-1780657511</td>\n",
       "      <td>-1296392817</td>\n",
       "      <td>562774890</td>\n",
       "      <td>TA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190926</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-1042629200</td>\n",
       "      <td>-93844220</td>\n",
       "      <td>0</td>\n",
       "      <td>36813700</td>\n",
       "      <td>332459820</td>\n",
       "      <td>303475130</td>\n",
       "      <td>88886850</td>\n",
       "      <td>-14986909680</td>\n",
       "      <td>-3678402103</td>\n",
       "      <td>-374837920</td>\n",
       "      <td>PP</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190927</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-985068810</td>\n",
       "      <td>-186478880</td>\n",
       "      <td>0</td>\n",
       "      <td>47301150</td>\n",
       "      <td>220268640</td>\n",
       "      <td>125696610</td>\n",
       "      <td>616100210</td>\n",
       "      <td>-11863777349</td>\n",
       "      <td>-2225288250</td>\n",
       "      <td>-162181080</td>\n",
       "      <td>TA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190930</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-880631850</td>\n",
       "      <td>86940540</td>\n",
       "      <td>0</td>\n",
       "      <td>29221680</td>\n",
       "      <td>0</td>\n",
       "      <td>130791060</td>\n",
       "      <td>417302400</td>\n",
       "      <td>-13871758457</td>\n",
       "      <td>-2878440759</td>\n",
       "      <td>-216376170</td>\n",
       "      <td>TA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191008</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-996712620</td>\n",
       "      <td>72083340</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>300493090</td>\n",
       "      <td>192967240</td>\n",
       "      <td>561371250</td>\n",
       "      <td>-12392693139</td>\n",
       "      <td>-2085598610</td>\n",
       "      <td>130202300</td>\n",
       "      <td>TA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191009</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-917386380</td>\n",
       "      <td>164659320</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>253025460</td>\n",
       "      <td>136452330</td>\n",
       "      <td>723469915</td>\n",
       "      <td>-13120403777</td>\n",
       "      <td>-3427403563</td>\n",
       "      <td>360220645</td>\n",
       "      <td>TA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191010</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-891314620</td>\n",
       "      <td>33644250</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-162041040</td>\n",
       "      <td>399125000</td>\n",
       "      <td>-14316810050</td>\n",
       "      <td>-3718143650</td>\n",
       "      <td>-620586410</td>\n",
       "      <td>TA</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191011</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-1008024000</td>\n",
       "      <td>-149258160</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-2524500</td>\n",
       "      <td>-12907616577</td>\n",
       "      <td>-3209554979</td>\n",
       "      <td>-1159806660</td>\n",
       "      <td>V</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191014</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-916308360</td>\n",
       "      <td>57152130</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>402534500</td>\n",
       "      <td>-106989120</td>\n",
       "      <td>218248565</td>\n",
       "      <td>-9968036048</td>\n",
       "      <td>-3103442206</td>\n",
       "      <td>-345362285</td>\n",
       "      <td>PP</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191015</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-967017920</td>\n",
       "      <td>11405440</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>287519235</td>\n",
       "      <td>-221874940</td>\n",
       "      <td>-255689775</td>\n",
       "      <td>-11249415180</td>\n",
       "      <td>-2698891850</td>\n",
       "      <td>-1145657960</td>\n",
       "      <td>PP</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191016</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-865666290</td>\n",
       "      <td>-182838600</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-7286240</td>\n",
       "      <td>-189615090</td>\n",
       "      <td>-16452210831</td>\n",
       "      <td>-4353627145</td>\n",
       "      <td>-1245406220</td>\n",
       "      <td>V</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191017</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-870327360</td>\n",
       "      <td>-46443740</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>275839230</td>\n",
       "      <td>-123299350</td>\n",
       "      <td>143266840</td>\n",
       "      <td>-11449710501</td>\n",
       "      <td>-4195548682</td>\n",
       "      <td>-620964380</td>\n",
       "      <td>PP</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191018</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-616892400</td>\n",
       "      <td>-104525490</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>179795520</td>\n",
       "      <td>-49694430</td>\n",
       "      <td>-13522505129</td>\n",
       "      <td>-3842141973</td>\n",
       "      <td>-591316800</td>\n",
       "      <td>BU</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191021</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-807723720</td>\n",
       "      <td>-439148150</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>225988245</td>\n",
       "      <td>-172419030</td>\n",
       "      <td>-304297260</td>\n",
       "      <td>-7767284078</td>\n",
       "      <td>-4192949941</td>\n",
       "      <td>-1497599915</td>\n",
       "      <td>PP</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191022</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-808498710</td>\n",
       "      <td>-80171880</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>-121987920</td>\n",
       "      <td>-20485860</td>\n",
       "      <td>-4448599039</td>\n",
       "      <td>-3111800133</td>\n",
       "      <td>-1031144370</td>\n",
       "      <td>V</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191023</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-923530780</td>\n",
       "      <td>-405153000</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>130605160</td>\n",
       "      <td>13007865</td>\n",
       "      <td>-4238682870</td>\n",
       "      <td>-2530019399</td>\n",
       "      <td>-1185070755</td>\n",
       "      <td>BU</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191024</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-899125900</td>\n",
       "      <td>-184867110</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>343748160</td>\n",
       "      <td>-128119850</td>\n",
       "      <td>247225810</td>\n",
       "      <td>4504947387</td>\n",
       "      <td>-1117708206</td>\n",
       "      <td>-621138890</td>\n",
       "      <td>PP</td>\n",
       "      <td>RU</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                RU         MA  V          L         PP         BU  \\\n",
       "date     会员简称                                                              \n",
       "20190920 海通期货  -799167600   22839180  0  498086400  225910000 -127382530   \n",
       "20190923 海通期货  -857010960  165942600  0  654374000          0          0   \n",
       "20190924 海通期货  -967891680  163540080  0  391617030          0  148707000   \n",
       "20190925 海通期货 -1042963470  159498430  0  309569320  330986565  303896740   \n",
       "20190926 海通期货 -1042629200  -93844220  0   36813700  332459820  303475130   \n",
       "20190927 海通期货  -985068810 -186478880  0   47301150  220268640  125696610   \n",
       "20190930 海通期货  -880631850   86940540  0   29221680          0  130791060   \n",
       "20191008 海通期货  -996712620   72083340  0          0  300493090  192967240   \n",
       "20191009 海通期货  -917386380  164659320  0          0  253025460  136452330   \n",
       "20191010 海通期货  -891314620   33644250  0          0          0 -162041040   \n",
       "20191011 海通期货 -1008024000 -149258160  0          0          0          0   \n",
       "20191014 海通期货  -916308360   57152130  0          0  402534500 -106989120   \n",
       "20191015 海通期货  -967017920   11405440  0          0  287519235 -221874940   \n",
       "20191016 海通期货  -865666290 -182838600  0          0          0   -7286240   \n",
       "20191017 海通期货  -870327360  -46443740  0          0  275839230 -123299350   \n",
       "20191018 海通期货  -616892400 -104525490  0          0          0  179795520   \n",
       "20191021 海通期货  -807723720 -439148150  0          0  225988245 -172419030   \n",
       "20191022 海通期货  -808498710  -80171880  0          0          0 -121987920   \n",
       "20191023 海通期货  -923530780 -405153000  0          0          0  130605160   \n",
       "20191024 海通期货  -899125900 -184867110  0          0  343748160 -128119850   \n",
       "\n",
       "variety               TA         商品板块         工业品        化工板块 max min  \n",
       "date     会员简称                                                          \n",
       "20190920 海通期货 -551954295  -3367909283 -2090441051  -731668845   L  RU  \n",
       "20190923 海通期货  508981530    902773365  -243088285   472287170   L  RU  \n",
       "20190924 海通期货  -65240430  -3829352983 -2584954486  -329268000   L  RU  \n",
       "20190925 海通期货  501787305  -1780657511 -1296392817   562774890  TA  RU  \n",
       "20190926 海通期货   88886850 -14986909680 -3678402103  -374837920  PP  RU  \n",
       "20190927 海通期货  616100210 -11863777349 -2225288250  -162181080  TA  RU  \n",
       "20190930 海通期货  417302400 -13871758457 -2878440759  -216376170  TA  RU  \n",
       "20191008 海通期货  561371250 -12392693139 -2085598610   130202300  TA  RU  \n",
       "20191009 海通期货  723469915 -13120403777 -3427403563   360220645  TA  RU  \n",
       "20191010 海通期货  399125000 -14316810050 -3718143650  -620586410  TA  RU  \n",
       "20191011 海通期货   -2524500 -12907616577 -3209554979 -1159806660   V  RU  \n",
       "20191014 海通期货  218248565  -9968036048 -3103442206  -345362285  PP  RU  \n",
       "20191015 海通期货 -255689775 -11249415180 -2698891850 -1145657960  PP  RU  \n",
       "20191016 海通期货 -189615090 -16452210831 -4353627145 -1245406220   V  RU  \n",
       "20191017 海通期货  143266840 -11449710501 -4195548682  -620964380  PP  RU  \n",
       "20191018 海通期货  -49694430 -13522505129 -3842141973  -591316800  BU  RU  \n",
       "20191021 海通期货 -304297260  -7767284078 -4192949941 -1497599915  PP  RU  \n",
       "20191022 海通期货  -20485860  -4448599039 -3111800133 -1031144370   V  RU  \n",
       "20191023 海通期货   13007865  -4238682870 -2530019399 -1185070755  BU  RU  \n",
       "20191024 海通期货  247225810   4504947387 -1117708206  -621138890  PP  RU  "
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pymongo\n",
    "import pandas as pd\n",
    "import matplotlib as plt\n",
    "from pandas import Series,DataFrame\n",
    "pd.set_option('display.width', None)  # 设置字符显示宽度\n",
    "pd.set_option('display.max_rows', None)  # 设置显示最大行\n",
    "pd.set_option('display.max_columns', None)  # 设置显示最大行\n",
    "#二行即可搞定画图中文乱码\n",
    "plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签\n",
    "plt.rcParams['axes.unicode_minus']=False #用来正常显示负号\n",
    "from IPython.core.display import display, HTML\n",
    "display(HTML(\"<style>.container { width:100% !important; }</style>\"))\n",
    "\n",
    "date = '20190812'\n",
    "#连接数据库\n",
    "client = pymongo.MongoClient('localhost',27017)\n",
    "futures = client.futures\n",
    "market = futures.indexMarket\n",
    "unit = futures.unit\n",
    "position = futures.position\n",
    "\n",
    "#加载数据\n",
    "market = DataFrame(list(market.find({'date': {'$gte': date}})))\n",
    "unit = DataFrame(list(unit.find()))\n",
    "position = DataFrame(list(position.find({'date': {'$gte': date}})))\n",
    "\n",
    "#大写字母\n",
    "position=position.rename(columns={'var':'variety'})\n",
    "\n",
    "#删除/选取某行含有特殊数值的列\n",
    "position=position.dropna()\n",
    "#选择需要显示的字段\n",
    "\n",
    "data1=market[['date','variety','set_close']]\n",
    "\n",
    "data2=unit[[ 'variety','unit']]\n",
    "position=position[['date','variety','symbol','long_party_name','long_openIntr', 'long_openIntr_chg','short_party_name','short_openIntr', 'short_openIntr_chg']]\n",
    "\n",
    "#查询会员\n",
    "members='海通期货'\n",
    "data3=position[(position['long_party_name'] == members)]\n",
    "\n",
    "#汇总合约\n",
    "data3=data3[['date','variety','long_party_name','long_openIntr']]\n",
    "\n",
    "data3=data3.groupby(['date','variety','long_party_name'])[['long_openIntr']].sum()\n",
    "\n",
    "data4=position[(position['short_party_name'] == members)]\n",
    "data4=data4[['date','variety','short_party_name','short_openIntr']]\n",
    "data4=data4.groupby(['date','variety','short_party_name'])[['short_openIntr']].sum()\n",
    "\n",
    "\n",
    "#并集\n",
    "data5=pd.merge(data3,data4, on=['date','variety'],how='outer')\n",
    "data5['会员简称']=data5.apply(lambda x: members,axis=1)\n",
    "\n",
    "#nan缺失值填充fillna()为0\n",
    "data5=data5.fillna(0)\n",
    "data5['净持仓']=data5.apply(lambda x: x['long_openIntr']-x['short_openIntr'],axis=1)\n",
    "\n",
    "# df['当日涨幅']=df.apply(lambda x: x['收盘']-x['收盘'].shift(1)-1,axis=1)\n",
    "#选择需要显示的字段\n",
    "data5=data5[['会员简称','long_openIntr','short_openIntr','净持仓']]\n",
    "data5=data5.reset_index(['variety','date'])\n",
    "netpostion=data5.set_index('date')\n",
    "\n",
    "netpostion=data5.pivot_table('净持仓',index='date',columns='variety',fill_value=0)\n",
    "\n",
    "#合约价值\n",
    "contractValue=pd.merge(data1,data2,how='left',sort=False).drop_duplicates()\n",
    "contractValue['contractValue'] = contractValue.apply(lambda x: x['set_close']*x['unit'],axis=1)\n",
    "contractValue=contractValue[['date','variety','contractValue']]\n",
    "\n",
    "#值替换replace()\n",
    "# contractValue=contractValue.replace(['TA'],'PTA')\n",
    "sz=pd.merge(data5,contractValue,on=['date','variety'],how='left')\n",
    "\n",
    "#净持仓价值\n",
    "sz['净持仓价值']=sz.apply(lambda x: x['净持仓']*x['contractValue'],axis=1)\n",
    "sz=sz[['date','variety','会员简称','净持仓价值']]\n",
    "sz=sz.sort_values(by='净持仓价值')\n",
    "sz=sz.pivot_table('净持仓价值',index=['date','会员简称'],columns='variety',fill_value=0)\n",
    "sz=sz.copy()\n",
    "#所有品种\n",
    "sz\n",
    "sz['化工板块']=sz[['RU','MA','V','L','PP','BU','TA']].sum(axis=1)\n",
    "sz['油脂板块']=sz[['Y','P','OI']].sum(axis=1)\n",
    "sz['有色板块']=sz[['CU','AL','ZN','NI','PB']].sum(axis=1)\n",
    "sz['黑色板块']=sz[['RB','HC','ZC','J','JM','I']].sum(axis=1)\n",
    "sz['黄金白银']=sz[['AU','AG']].sum(axis=1)\n",
    "sz['工业品']=sz[['CU','AL','ZN','NI','PB','RB','FG','RU','L','V','TA','MA','PP','JM','J','ZC','I','BU','HC','SM','FU']].sum(axis=1)\n",
    "sz['农产品']=sz[['A','C','M','RM','Y','P','OI','CF','SR','JD','CS','AP']].sum(axis=1)\n",
    "sz['商品板块']=sz.sum(axis=1)\n",
    "\n",
    "\n",
    "chemical=sz.copy()\n",
    "chemical=chemical[['RU','MA','V','L','PP','BU','TA','商品板块','工业品','化工板块']]\n",
    "chemical['max']=chemical[['RU','MA','V','L','PP','BU','TA']].idxmax(axis=1)\n",
    "chemical['min']=chemical[['RU','MA','V','L','PP','BU']].idxmin(axis=1)\n",
    "chemical['20190920':]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "写入OK\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "from pymongo import MongoClient\n",
    "# 连接数据库\n",
    "client = MongoClient('localhost', 27017)\n",
    "db = client.futures\n",
    "flow = db.flows\n",
    "chemical = chemical.reset_index()\n",
    "\n",
    "futures = client.futures\n",
    "flows = futures.flows\n",
    "flows.insert_many(json.loads(chemical.T.to_json()).values())\n",
    "print(\"写入OK\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>RB</th>\n",
       "      <th>HC</th>\n",
       "      <th>ZC</th>\n",
       "      <th>J</th>\n",
       "      <th>JM</th>\n",
       "      <th>I</th>\n",
       "      <th>黑色板块</th>\n",
       "      <th>工业品</th>\n",
       "      <th>商品板块</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20190920</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-567214800</td>\n",
       "      <td>-115428240</td>\n",
       "      <td>0</td>\n",
       "      <td>62952500</td>\n",
       "      <td>-93639060</td>\n",
       "      <td>-501732000</td>\n",
       "      <td>-1215061600</td>\n",
       "      <td>-2090441051</td>\n",
       "      <td>-3367909283</td>\n",
       "      <td>J</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190923</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-552930780</td>\n",
       "      <td>-125554000</td>\n",
       "      <td>198316800</td>\n",
       "      <td>318582000</td>\n",
       "      <td>-12830400</td>\n",
       "      <td>-302827500</td>\n",
       "      <td>-477243880</td>\n",
       "      <td>-243088285</td>\n",
       "      <td>902773365</td>\n",
       "      <td>J</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190924</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-491929380</td>\n",
       "      <td>-150588900</td>\n",
       "      <td>182677500</td>\n",
       "      <td>-638826500</td>\n",
       "      <td>-183912960</td>\n",
       "      <td>-440418500</td>\n",
       "      <td>-1722998740</td>\n",
       "      <td>-2584954486</td>\n",
       "      <td>-3829352983</td>\n",
       "      <td>ZC</td>\n",
       "      <td>J</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190925</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-303874300</td>\n",
       "      <td>-139744350</td>\n",
       "      <td>43985800</td>\n",
       "      <td>24053800</td>\n",
       "      <td>-245628600</td>\n",
       "      <td>-92032200</td>\n",
       "      <td>-713239850</td>\n",
       "      <td>-1296392817</td>\n",
       "      <td>-1780657511</td>\n",
       "      <td>ZC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190926</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-632270520</td>\n",
       "      <td>-59305180</td>\n",
       "      <td>-178020000</td>\n",
       "      <td>-449999600</td>\n",
       "      <td>-354791760</td>\n",
       "      <td>-344198600</td>\n",
       "      <td>-2018585660</td>\n",
       "      <td>-3678402103</td>\n",
       "      <td>-14986909680</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190927</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-544434960</td>\n",
       "      <td>-38436840</td>\n",
       "      <td>-188339000</td>\n",
       "      <td>-257487600</td>\n",
       "      <td>-253825380</td>\n",
       "      <td>-205376000</td>\n",
       "      <td>-1487899780</td>\n",
       "      <td>-2225288250</td>\n",
       "      <td>-11863777349</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190930</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-904651600</td>\n",
       "      <td>96111360</td>\n",
       "      <td>-186659900</td>\n",
       "      <td>-407316700</td>\n",
       "      <td>-395924760</td>\n",
       "      <td>-400811400</td>\n",
       "      <td>-2199253000</td>\n",
       "      <td>-2878440759</td>\n",
       "      <td>-13871758457</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191008</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-985070720</td>\n",
       "      <td>80143180</td>\n",
       "      <td>-212602400</td>\n",
       "      <td>-212214000</td>\n",
       "      <td>-337471080</td>\n",
       "      <td>-489065200</td>\n",
       "      <td>-2156280220</td>\n",
       "      <td>-2085598610</td>\n",
       "      <td>-12392693139</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191009</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-976446000</td>\n",
       "      <td>-38441250</td>\n",
       "      <td>-194764500</td>\n",
       "      <td>-970170300</td>\n",
       "      <td>-280125720</td>\n",
       "      <td>-844486500</td>\n",
       "      <td>-3304434270</td>\n",
       "      <td>-3427403563</td>\n",
       "      <td>-13120403777</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191010</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-1583245750</td>\n",
       "      <td>50741150</td>\n",
       "      <td>-246304800</td>\n",
       "      <td>-593682900</td>\n",
       "      <td>-162655020</td>\n",
       "      <td>81690300</td>\n",
       "      <td>-2453457020</td>\n",
       "      <td>-3718143650</td>\n",
       "      <td>-14316810050</td>\n",
       "      <td>I</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191011</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-1394767850</td>\n",
       "      <td>172822620</td>\n",
       "      <td>-272812000</td>\n",
       "      <td>-447144000</td>\n",
       "      <td>-204122880</td>\n",
       "      <td>-45187600</td>\n",
       "      <td>-2191211710</td>\n",
       "      <td>-3209554979</td>\n",
       "      <td>-12907616577</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191014</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-981879600</td>\n",
       "      <td>158893680</td>\n",
       "      <td>-305559400</td>\n",
       "      <td>-982638800</td>\n",
       "      <td>-393673800</td>\n",
       "      <td>-65980800</td>\n",
       "      <td>-2570838720</td>\n",
       "      <td>-3103442206</td>\n",
       "      <td>-9968036048</td>\n",
       "      <td>HC</td>\n",
       "      <td>J</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191015</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-1169600540</td>\n",
       "      <td>182435000</td>\n",
       "      <td>-310468600</td>\n",
       "      <td>-633523200</td>\n",
       "      <td>-121694580</td>\n",
       "      <td>-179979800</td>\n",
       "      <td>-2232831720</td>\n",
       "      <td>-2698891850</td>\n",
       "      <td>-11249415180</td>\n",
       "      <td>HC</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191016</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-649601260</td>\n",
       "      <td>48841650</td>\n",
       "      <td>-388366000</td>\n",
       "      <td>-1204305600</td>\n",
       "      <td>-376018200</td>\n",
       "      <td>-1024671600</td>\n",
       "      <td>-3594121010</td>\n",
       "      <td>-4353627145</td>\n",
       "      <td>-16452210831</td>\n",
       "      <td>HC</td>\n",
       "      <td>J</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191017</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-584038500</td>\n",
       "      <td>89613930</td>\n",
       "      <td>-365099400</td>\n",
       "      <td>-1011978100</td>\n",
       "      <td>-281283600</td>\n",
       "      <td>-788007400</td>\n",
       "      <td>-2940793070</td>\n",
       "      <td>-4195548682</td>\n",
       "      <td>-11449710501</td>\n",
       "      <td>HC</td>\n",
       "      <td>J</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191018</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-783795810</td>\n",
       "      <td>-41201650</td>\n",
       "      <td>-358515000</td>\n",
       "      <td>-833704200</td>\n",
       "      <td>-265633380</td>\n",
       "      <td>-461038000</td>\n",
       "      <td>-2743888040</td>\n",
       "      <td>-3842141973</td>\n",
       "      <td>-13522505129</td>\n",
       "      <td>HC</td>\n",
       "      <td>J</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191021</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-720704460</td>\n",
       "      <td>-71733030</td>\n",
       "      <td>-349587000</td>\n",
       "      <td>-1303364400</td>\n",
       "      <td>-94030800</td>\n",
       "      <td>-923004200</td>\n",
       "      <td>-3462423890</td>\n",
       "      <td>-4192949941</td>\n",
       "      <td>-7767284078</td>\n",
       "      <td>HC</td>\n",
       "      <td>J</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191022</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-682564800</td>\n",
       "      <td>91877150</td>\n",
       "      <td>-327713400</td>\n",
       "      <td>-1110154800</td>\n",
       "      <td>-78365400</td>\n",
       "      <td>-684460800</td>\n",
       "      <td>-2791382050</td>\n",
       "      <td>-3111800133</td>\n",
       "      <td>-4448599039</td>\n",
       "      <td>HC</td>\n",
       "      <td>J</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191023</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-801989760</td>\n",
       "      <td>-122252760</td>\n",
       "      <td>-336268800</td>\n",
       "      <td>-302139000</td>\n",
       "      <td>-36600000</td>\n",
       "      <td>-725592000</td>\n",
       "      <td>-2324842320</td>\n",
       "      <td>-2530019399</td>\n",
       "      <td>-4238682870</td>\n",
       "      <td>JM</td>\n",
       "      <td>RB</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191024</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-429477640</td>\n",
       "      <td>-340650060</td>\n",
       "      <td>-315447600</td>\n",
       "      <td>-605378000</td>\n",
       "      <td>0</td>\n",
       "      <td>-680187500</td>\n",
       "      <td>-2371140800</td>\n",
       "      <td>-1117708206</td>\n",
       "      <td>4504947387</td>\n",
       "      <td>JM</td>\n",
       "      <td>I</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                RB         HC         ZC           J         JM  \\\n",
       "date     会员简称                                                            \n",
       "20190920 海通期货  -567214800 -115428240          0    62952500  -93639060   \n",
       "20190923 海通期货  -552930780 -125554000  198316800   318582000  -12830400   \n",
       "20190924 海通期货  -491929380 -150588900  182677500  -638826500 -183912960   \n",
       "20190925 海通期货  -303874300 -139744350   43985800    24053800 -245628600   \n",
       "20190926 海通期货  -632270520  -59305180 -178020000  -449999600 -354791760   \n",
       "20190927 海通期货  -544434960  -38436840 -188339000  -257487600 -253825380   \n",
       "20190930 海通期货  -904651600   96111360 -186659900  -407316700 -395924760   \n",
       "20191008 海通期货  -985070720   80143180 -212602400  -212214000 -337471080   \n",
       "20191009 海通期货  -976446000  -38441250 -194764500  -970170300 -280125720   \n",
       "20191010 海通期货 -1583245750   50741150 -246304800  -593682900 -162655020   \n",
       "20191011 海通期货 -1394767850  172822620 -272812000  -447144000 -204122880   \n",
       "20191014 海通期货  -981879600  158893680 -305559400  -982638800 -393673800   \n",
       "20191015 海通期货 -1169600540  182435000 -310468600  -633523200 -121694580   \n",
       "20191016 海通期货  -649601260   48841650 -388366000 -1204305600 -376018200   \n",
       "20191017 海通期货  -584038500   89613930 -365099400 -1011978100 -281283600   \n",
       "20191018 海通期货  -783795810  -41201650 -358515000  -833704200 -265633380   \n",
       "20191021 海通期货  -720704460  -71733030 -349587000 -1303364400  -94030800   \n",
       "20191022 海通期货  -682564800   91877150 -327713400 -1110154800  -78365400   \n",
       "20191023 海通期货  -801989760 -122252760 -336268800  -302139000  -36600000   \n",
       "20191024 海通期货  -429477640 -340650060 -315447600  -605378000          0   \n",
       "\n",
       "variety                 I        黑色板块         工业品         商品板块 max min  \n",
       "date     会员简称                                                           \n",
       "20190920 海通期货  -501732000 -1215061600 -2090441051  -3367909283   J  RB  \n",
       "20190923 海通期货  -302827500  -477243880  -243088285    902773365   J  RB  \n",
       "20190924 海通期货  -440418500 -1722998740 -2584954486  -3829352983  ZC   J  \n",
       "20190925 海通期货   -92032200  -713239850 -1296392817  -1780657511  ZC  RB  \n",
       "20190926 海通期货  -344198600 -2018585660 -3678402103 -14986909680  HC  RB  \n",
       "20190927 海通期货  -205376000 -1487899780 -2225288250 -11863777349  HC  RB  \n",
       "20190930 海通期货  -400811400 -2199253000 -2878440759 -13871758457  HC  RB  \n",
       "20191008 海通期货  -489065200 -2156280220 -2085598610 -12392693139  HC  RB  \n",
       "20191009 海通期货  -844486500 -3304434270 -3427403563 -13120403777  HC  RB  \n",
       "20191010 海通期货    81690300 -2453457020 -3718143650 -14316810050   I  RB  \n",
       "20191011 海通期货   -45187600 -2191211710 -3209554979 -12907616577  HC  RB  \n",
       "20191014 海通期货   -65980800 -2570838720 -3103442206  -9968036048  HC   J  \n",
       "20191015 海通期货  -179979800 -2232831720 -2698891850 -11249415180  HC  RB  \n",
       "20191016 海通期货 -1024671600 -3594121010 -4353627145 -16452210831  HC   J  \n",
       "20191017 海通期货  -788007400 -2940793070 -4195548682 -11449710501  HC   J  \n",
       "20191018 海通期货  -461038000 -2743888040 -3842141973 -13522505129  HC   J  \n",
       "20191021 海通期货  -923004200 -3462423890 -4192949941  -7767284078  HC   J  \n",
       "20191022 海通期货  -684460800 -2791382050 -3111800133  -4448599039  HC   J  \n",
       "20191023 海通期货  -725592000 -2324842320 -2530019399  -4238682870  JM  RB  \n",
       "20191024 海通期货  -680187500 -2371140800 -1117708206   4504947387  JM   I  "
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "黑色板块=sz.copy()\n",
    "黑色板块=黑色板块[['RB','HC','ZC','J','JM','I','黑色板块','工业品','商品板块']] \n",
    "黑色板块['max']=黑色板块[['RB','HC','ZC','J','JM','I']].idxmax(axis=1) \n",
    "黑色板块['min']=黑色板块[['RB','HC','ZC','J','JM','I']].idxmin(axis=1)\n",
    "黑色板块['20190920':]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "写入OK\n"
     ]
    }
   ],
   "source": [
    "import json\n",
    "from pymongo import MongoClient\n",
    "# 连接数据库\n",
    "client = MongoClient('localhost', 27017)\n",
    "db = client.futures\n",
    "flow = db.flows\n",
    "黑色板块=sz.copy()\n",
    "黑色板块=黑色板块[['RB','HC','ZC','J','JM','I','黑色板块','工业品','商品板块']] \n",
    "黑色板块['max']=黑色板块[['RB','HC','ZC','J','JM','I']].idxmax(axis=1) \n",
    "黑色板块['min']=黑色板块[['RB','HC','ZC','J','JM','I']].idxmin(axis=1)\n",
    "df = 黑色板块.reset_index()\n",
    "flow.insert_many(json.loads(df.T.to_json()).values())\n",
    "print(\"写入OK\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>Y</th>\n",
       "      <th>P</th>\n",
       "      <th>OI</th>\n",
       "      <th>油脂板块</th>\n",
       "      <th>农产品</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20190920</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>236490480</td>\n",
       "      <td>248209840</td>\n",
       "      <td>-167490600</td>\n",
       "      <td>317209720</td>\n",
       "      <td>268123215</td>\n",
       "      <td>P</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190923</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>205590900</td>\n",
       "      <td>288043350</td>\n",
       "      <td>0</td>\n",
       "      <td>493634250</td>\n",
       "      <td>-461551900</td>\n",
       "      <td>P</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190924</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>47920000</td>\n",
       "      <td>231041130</td>\n",
       "      <td>-180223850</td>\n",
       "      <td>98737280</td>\n",
       "      <td>41765095</td>\n",
       "      <td>P</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190925</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>102623950</td>\n",
       "      <td>0</td>\n",
       "      <td>-174435840</td>\n",
       "      <td>-71811890</td>\n",
       "      <td>1042793570</td>\n",
       "      <td>Y</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190926</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>25171960</td>\n",
       "      <td>0</td>\n",
       "      <td>-162065280</td>\n",
       "      <td>-136893320</td>\n",
       "      <td>-1319448910</td>\n",
       "      <td>Y</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190927</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-523773710</td>\n",
       "      <td>156995640</td>\n",
       "      <td>-145625350</td>\n",
       "      <td>-512403420</td>\n",
       "      <td>-1649697890</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190930</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-484581230</td>\n",
       "      <td>151850900</td>\n",
       "      <td>-132267850</td>\n",
       "      <td>-464998180</td>\n",
       "      <td>-1550939645</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191008</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-607027140</td>\n",
       "      <td>154900270</td>\n",
       "      <td>-176945760</td>\n",
       "      <td>-629072630</td>\n",
       "      <td>-1423140775</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191009</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-642128270</td>\n",
       "      <td>206059040</td>\n",
       "      <td>-158108240</td>\n",
       "      <td>-594177470</td>\n",
       "      <td>-208484145</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191010</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-706012830</td>\n",
       "      <td>213666720</td>\n",
       "      <td>-148019280</td>\n",
       "      <td>-640365390</td>\n",
       "      <td>-338457945</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191011</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-692274900</td>\n",
       "      <td>228931780</td>\n",
       "      <td>-144491000</td>\n",
       "      <td>-607834120</td>\n",
       "      <td>-548302285</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191014</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-662586060</td>\n",
       "      <td>189864600</td>\n",
       "      <td>-164284680</td>\n",
       "      <td>-637006140</td>\n",
       "      <td>78015480</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191015</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-560225870</td>\n",
       "      <td>191402640</td>\n",
       "      <td>-117985280</td>\n",
       "      <td>-486808510</td>\n",
       "      <td>70594190</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191016</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-566691120</td>\n",
       "      <td>271036780</td>\n",
       "      <td>-128266800</td>\n",
       "      <td>-423921140</td>\n",
       "      <td>-112197875</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191017</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-493990200</td>\n",
       "      <td>262045750</td>\n",
       "      <td>-140392360</td>\n",
       "      <td>-372336810</td>\n",
       "      <td>1227309105</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191018</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-458662050</td>\n",
       "      <td>237831930</td>\n",
       "      <td>-128719360</td>\n",
       "      <td>-349549480</td>\n",
       "      <td>419081290</td>\n",
       "      <td>P</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191021</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>409866770</td>\n",
       "      <td>272069400</td>\n",
       "      <td>-123541560</td>\n",
       "      <td>558394610</td>\n",
       "      <td>3066737470</td>\n",
       "      <td>Y</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191022</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>350486620</td>\n",
       "      <td>328186430</td>\n",
       "      <td>-124159490</td>\n",
       "      <td>554513560</td>\n",
       "      <td>2247064465</td>\n",
       "      <td>Y</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191023</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>440942280</td>\n",
       "      <td>318997720</td>\n",
       "      <td>-125451460</td>\n",
       "      <td>634488540</td>\n",
       "      <td>1888012420</td>\n",
       "      <td>Y</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191024</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>1079814880</td>\n",
       "      <td>399839250</td>\n",
       "      <td>-105978960</td>\n",
       "      <td>1373675170</td>\n",
       "      <td>3962276880</td>\n",
       "      <td>Y</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                 Y          P         OI        油脂板块         农产品 max  \\\n",
       "date     会员简称                                                                 \n",
       "20190920 海通期货   236490480  248209840 -167490600   317209720   268123215   P   \n",
       "20190923 海通期货   205590900  288043350          0   493634250  -461551900   P   \n",
       "20190924 海通期货    47920000  231041130 -180223850    98737280    41765095   P   \n",
       "20190925 海通期货   102623950          0 -174435840   -71811890  1042793570   Y   \n",
       "20190926 海通期货    25171960          0 -162065280  -136893320 -1319448910   Y   \n",
       "20190927 海通期货  -523773710  156995640 -145625350  -512403420 -1649697890   P   \n",
       "20190930 海通期货  -484581230  151850900 -132267850  -464998180 -1550939645   P   \n",
       "20191008 海通期货  -607027140  154900270 -176945760  -629072630 -1423140775   P   \n",
       "20191009 海通期货  -642128270  206059040 -158108240  -594177470  -208484145   P   \n",
       "20191010 海通期货  -706012830  213666720 -148019280  -640365390  -338457945   P   \n",
       "20191011 海通期货  -692274900  228931780 -144491000  -607834120  -548302285   P   \n",
       "20191014 海通期货  -662586060  189864600 -164284680  -637006140    78015480   P   \n",
       "20191015 海通期货  -560225870  191402640 -117985280  -486808510    70594190   P   \n",
       "20191016 海通期货  -566691120  271036780 -128266800  -423921140  -112197875   P   \n",
       "20191017 海通期货  -493990200  262045750 -140392360  -372336810  1227309105   P   \n",
       "20191018 海通期货  -458662050  237831930 -128719360  -349549480   419081290   P   \n",
       "20191021 海通期货   409866770  272069400 -123541560   558394610  3066737470   Y   \n",
       "20191022 海通期货   350486620  328186430 -124159490   554513560  2247064465   Y   \n",
       "20191023 海通期货   440942280  318997720 -125451460   634488540  1888012420   Y   \n",
       "20191024 海通期货  1079814880  399839250 -105978960  1373675170  3962276880   Y   \n",
       "\n",
       "variety       min  \n",
       "date     会员简称      \n",
       "20190920 海通期货  OI  \n",
       "20190923 海通期货  OI  \n",
       "20190924 海通期货  OI  \n",
       "20190925 海通期货  OI  \n",
       "20190926 海通期货  OI  \n",
       "20190927 海通期货   Y  \n",
       "20190930 海通期货   Y  \n",
       "20191008 海通期货   Y  \n",
       "20191009 海通期货   Y  \n",
       "20191010 海通期货   Y  \n",
       "20191011 海通期货   Y  \n",
       "20191014 海通期货   Y  \n",
       "20191015 海通期货   Y  \n",
       "20191016 海通期货   Y  \n",
       "20191017 海通期货   Y  \n",
       "20191018 海通期货   Y  \n",
       "20191021 海通期货  OI  \n",
       "20191022 海通期货  OI  \n",
       "20191023 海通期货  OI  \n",
       "20191024 海通期货  OI  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "oil=sz.copy()\n",
    "oil=oil[['Y','P','OI','油脂板块','农产品']]\n",
    "oil['max']=oil[['Y','P','OI']].idxmax(axis=1) \n",
    "oil['min']=oil[['Y','P','OI']].idxmin(axis=1)\n",
    "oil['20190920':]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>CU</th>\n",
       "      <th>AL</th>\n",
       "      <th>ZN</th>\n",
       "      <th>NI</th>\n",
       "      <th>PB</th>\n",
       "      <th>有色板块</th>\n",
       "      <th>工业品</th>\n",
       "      <th>商品板块</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20190920</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-391716780</td>\n",
       "      <td>10813280</td>\n",
       "      <td>15781500</td>\n",
       "      <td>303111704</td>\n",
       "      <td>160849920</td>\n",
       "      <td>98839624</td>\n",
       "      <td>-2090441051</td>\n",
       "      <td>-3367909283</td>\n",
       "      <td>NI</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190923</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-441713220</td>\n",
       "      <td>69592215</td>\n",
       "      <td>-55981530</td>\n",
       "      <td>190112160</td>\n",
       "      <td>210323080</td>\n",
       "      <td>-27667295</td>\n",
       "      <td>-243088285</td>\n",
       "      <td>902773365</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190924</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-257088695</td>\n",
       "      <td>85384800</td>\n",
       "      <td>-171467875</td>\n",
       "      <td>67044164</td>\n",
       "      <td>229808540</td>\n",
       "      <td>-46319066</td>\n",
       "      <td>-2584954486</td>\n",
       "      <td>-3829352983</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190925</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-640858635</td>\n",
       "      <td>119000980</td>\n",
       "      <td>-130391460</td>\n",
       "      <td>-314462392</td>\n",
       "      <td>269232930</td>\n",
       "      <td>-697478577</td>\n",
       "      <td>-1296392817</td>\n",
       "      <td>-1780657511</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190926</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-543247480</td>\n",
       "      <td>96735600</td>\n",
       "      <td>-167724075</td>\n",
       "      <td>-771858788</td>\n",
       "      <td>272986200</td>\n",
       "      <td>-1113108543</td>\n",
       "      <td>-3678402103</td>\n",
       "      <td>-14986909680</td>\n",
       "      <td>PB</td>\n",
       "      <td>NI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190927</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-866074695</td>\n",
       "      <td>116915000</td>\n",
       "      <td>3653715</td>\n",
       "      <td>219357990</td>\n",
       "      <td>282668660</td>\n",
       "      <td>-243479330</td>\n",
       "      <td>-2225288250</td>\n",
       "      <td>-11863777349</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190930</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-698827500</td>\n",
       "      <td>27735840</td>\n",
       "      <td>-141740895</td>\n",
       "      <td>226612176</td>\n",
       "      <td>415641600</td>\n",
       "      <td>-170578779</td>\n",
       "      <td>-2878440759</td>\n",
       "      <td>-13871758457</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191008</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-384654900</td>\n",
       "      <td>28353010</td>\n",
       "      <td>-180406750</td>\n",
       "      <td>326570895</td>\n",
       "      <td>418652230</td>\n",
       "      <td>208514485</td>\n",
       "      <td>-2085598610</td>\n",
       "      <td>-12392693139</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191009</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-701826650</td>\n",
       "      <td>16706400</td>\n",
       "      <td>-227696480</td>\n",
       "      <td>364832992</td>\n",
       "      <td>424671870</td>\n",
       "      <td>-123311868</td>\n",
       "      <td>-3427403563</td>\n",
       "      <td>-13120403777</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191010</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-1135632075</td>\n",
       "      <td>32294400</td>\n",
       "      <td>-123610080</td>\n",
       "      <td>797779015</td>\n",
       "      <td>421387700</td>\n",
       "      <td>-7781040</td>\n",
       "      <td>-3718143650</td>\n",
       "      <td>-14316810050</td>\n",
       "      <td>NI</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191011</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-1124685980</td>\n",
       "      <td>226392360</td>\n",
       "      <td>-122235870</td>\n",
       "      <td>1367736831</td>\n",
       "      <td>399249090</td>\n",
       "      <td>746456431</td>\n",
       "      <td>-3209554979</td>\n",
       "      <td>-12907616577</td>\n",
       "      <td>NI</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191014</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-944620515</td>\n",
       "      <td>155306250</td>\n",
       "      <td>89676060</td>\n",
       "      <td>821290389</td>\n",
       "      <td>457556400</td>\n",
       "      <td>579208584</td>\n",
       "      <td>-3103442206</td>\n",
       "      <td>-9968036048</td>\n",
       "      <td>NI</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191015</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>181923500</td>\n",
       "      <td>151993400</td>\n",
       "      <td>122861035</td>\n",
       "      <td>308352000</td>\n",
       "      <td>453698320</td>\n",
       "      <td>1218828255</td>\n",
       "      <td>-2698891850</td>\n",
       "      <td>-11249415180</td>\n",
       "      <td>PB</td>\n",
       "      <td>ZN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191016</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-150320540</td>\n",
       "      <td>422915640</td>\n",
       "      <td>57876840</td>\n",
       "      <td>391140000</td>\n",
       "      <td>447664815</td>\n",
       "      <td>1169276755</td>\n",
       "      <td>-4353627145</td>\n",
       "      <td>-16452210831</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191017</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-384887250</td>\n",
       "      <td>442576750</td>\n",
       "      <td>-239003190</td>\n",
       "      <td>-269759392</td>\n",
       "      <td>464752660</td>\n",
       "      <td>13679578</td>\n",
       "      <td>-4195548682</td>\n",
       "      <td>-11449710501</td>\n",
       "      <td>PB</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191018</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-889231290</td>\n",
       "      <td>571348530</td>\n",
       "      <td>-183849170</td>\n",
       "      <td>-188293938</td>\n",
       "      <td>455064000</td>\n",
       "      <td>-234961868</td>\n",
       "      <td>-3842141973</td>\n",
       "      <td>-13522505129</td>\n",
       "      <td>AL</td>\n",
       "      <td>CU</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191021</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>208538135</td>\n",
       "      <td>432722250</td>\n",
       "      <td>-67544400</td>\n",
       "      <td>-295892496</td>\n",
       "      <td>470929550</td>\n",
       "      <td>748753039</td>\n",
       "      <td>-4192949941</td>\n",
       "      <td>-7767284078</td>\n",
       "      <td>PB</td>\n",
       "      <td>NI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191022</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>348901385</td>\n",
       "      <td>571471730</td>\n",
       "      <td>-57831150</td>\n",
       "      <td>-585223718</td>\n",
       "      <td>457990440</td>\n",
       "      <td>735308687</td>\n",
       "      <td>-3111800133</td>\n",
       "      <td>-4448599039</td>\n",
       "      <td>AL</td>\n",
       "      <td>NI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191023</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>326944065</td>\n",
       "      <td>573404090</td>\n",
       "      <td>-100136625</td>\n",
       "      <td>-141848704</td>\n",
       "      <td>470853110</td>\n",
       "      <td>1129215936</td>\n",
       "      <td>-2530019399</td>\n",
       "      <td>-4238682870</td>\n",
       "      <td>AL</td>\n",
       "      <td>NI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191024</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>547955200</td>\n",
       "      <td>578938360</td>\n",
       "      <td>29172690</td>\n",
       "      <td>237416704</td>\n",
       "      <td>426713400</td>\n",
       "      <td>1820196354</td>\n",
       "      <td>-1117708206</td>\n",
       "      <td>4504947387</td>\n",
       "      <td>AL</td>\n",
       "      <td>ZN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                CU         AL         ZN          NI         PB  \\\n",
       "date     会员简称                                                            \n",
       "20190920 海通期货  -391716780   10813280   15781500   303111704  160849920   \n",
       "20190923 海通期货  -441713220   69592215  -55981530   190112160  210323080   \n",
       "20190924 海通期货  -257088695   85384800 -171467875    67044164  229808540   \n",
       "20190925 海通期货  -640858635  119000980 -130391460  -314462392  269232930   \n",
       "20190926 海通期货  -543247480   96735600 -167724075  -771858788  272986200   \n",
       "20190927 海通期货  -866074695  116915000    3653715   219357990  282668660   \n",
       "20190930 海通期货  -698827500   27735840 -141740895   226612176  415641600   \n",
       "20191008 海通期货  -384654900   28353010 -180406750   326570895  418652230   \n",
       "20191009 海通期货  -701826650   16706400 -227696480   364832992  424671870   \n",
       "20191010 海通期货 -1135632075   32294400 -123610080   797779015  421387700   \n",
       "20191011 海通期货 -1124685980  226392360 -122235870  1367736831  399249090   \n",
       "20191014 海通期货  -944620515  155306250   89676060   821290389  457556400   \n",
       "20191015 海通期货   181923500  151993400  122861035   308352000  453698320   \n",
       "20191016 海通期货  -150320540  422915640   57876840   391140000  447664815   \n",
       "20191017 海通期货  -384887250  442576750 -239003190  -269759392  464752660   \n",
       "20191018 海通期货  -889231290  571348530 -183849170  -188293938  455064000   \n",
       "20191021 海通期货   208538135  432722250  -67544400  -295892496  470929550   \n",
       "20191022 海通期货   348901385  571471730  -57831150  -585223718  457990440   \n",
       "20191023 海通期货   326944065  573404090 -100136625  -141848704  470853110   \n",
       "20191024 海通期货   547955200  578938360   29172690   237416704  426713400   \n",
       "\n",
       "variety              有色板块         工业品         商品板块 max min  \n",
       "date     会员简称                                               \n",
       "20190920 海通期货    98839624 -2090441051  -3367909283  NI  CU  \n",
       "20190923 海通期货   -27667295  -243088285    902773365  PB  CU  \n",
       "20190924 海通期货   -46319066 -2584954486  -3829352983  PB  CU  \n",
       "20190925 海通期货  -697478577 -1296392817  -1780657511  PB  CU  \n",
       "20190926 海通期货 -1113108543 -3678402103 -14986909680  PB  NI  \n",
       "20190927 海通期货  -243479330 -2225288250 -11863777349  PB  CU  \n",
       "20190930 海通期货  -170578779 -2878440759 -13871758457  PB  CU  \n",
       "20191008 海通期货   208514485 -2085598610 -12392693139  PB  CU  \n",
       "20191009 海通期货  -123311868 -3427403563 -13120403777  PB  CU  \n",
       "20191010 海通期货    -7781040 -3718143650 -14316810050  NI  CU  \n",
       "20191011 海通期货   746456431 -3209554979 -12907616577  NI  CU  \n",
       "20191014 海通期货   579208584 -3103442206  -9968036048  NI  CU  \n",
       "20191015 海通期货  1218828255 -2698891850 -11249415180  PB  ZN  \n",
       "20191016 海通期货  1169276755 -4353627145 -16452210831  PB  CU  \n",
       "20191017 海通期货    13679578 -4195548682 -11449710501  PB  CU  \n",
       "20191018 海通期货  -234961868 -3842141973 -13522505129  AL  CU  \n",
       "20191021 海通期货   748753039 -4192949941  -7767284078  PB  NI  \n",
       "20191022 海通期货   735308687 -3111800133  -4448599039  AL  NI  \n",
       "20191023 海通期货  1129215936 -2530019399  -4238682870  AL  NI  \n",
       "20191024 海通期货  1820196354 -1117708206   4504947387  AL  ZN  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "有色=sz.copy()\n",
    "有色=有色[['CU','AL','ZN','NI','PB','有色板块','工业品','商品板块']]\n",
    "有色['max']=有色[['CU','AL','ZN','NI','PB']].idxmax(axis=1) \n",
    "有色['min']=有色[['CU','AL','ZN','NI','PB']].idxmin(axis=1)\n",
    "有色['20190920':]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>A</th>\n",
       "      <th>C</th>\n",
       "      <th>M</th>\n",
       "      <th>RM</th>\n",
       "      <th>Y</th>\n",
       "      <th>P</th>\n",
       "      <th>OI</th>\n",
       "      <th>CF</th>\n",
       "      <th>SR</th>\n",
       "      <th>JD</th>\n",
       "      <th>CS</th>\n",
       "      <th>AP</th>\n",
       "      <th>农产品</th>\n",
       "      <th>max</th>\n",
       "      <th>min</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20190920</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>111016320</td>\n",
       "      <td>-375515400</td>\n",
       "      <td>358513250</td>\n",
       "      <td>0</td>\n",
       "      <td>236490480</td>\n",
       "      <td>248209840</td>\n",
       "      <td>-167490600</td>\n",
       "      <td>-519732675</td>\n",
       "      <td>552991320</td>\n",
       "      <td>110193760</td>\n",
       "      <td>-50734500</td>\n",
       "      <td>-235818580</td>\n",
       "      <td>268123215</td>\n",
       "      <td>SR</td>\n",
       "      <td>CF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190923</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>120200800</td>\n",
       "      <td>-382436180</td>\n",
       "      <td>119658000</td>\n",
       "      <td>25502750</td>\n",
       "      <td>205590900</td>\n",
       "      <td>288043350</td>\n",
       "      <td>0</td>\n",
       "      <td>-677341980</td>\n",
       "      <td>0</td>\n",
       "      <td>108248120</td>\n",
       "      <td>-53424000</td>\n",
       "      <td>-215593660</td>\n",
       "      <td>-461551900</td>\n",
       "      <td>P</td>\n",
       "      <td>CF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190924</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>30263970</td>\n",
       "      <td>-312366960</td>\n",
       "      <td>244772580</td>\n",
       "      <td>139541560</td>\n",
       "      <td>47920000</td>\n",
       "      <td>231041130</td>\n",
       "      <td>-180223850</td>\n",
       "      <td>-688653315</td>\n",
       "      <td>596871800</td>\n",
       "      <td>121108320</td>\n",
       "      <td>-85050740</td>\n",
       "      <td>-103459400</td>\n",
       "      <td>41765095</td>\n",
       "      <td>SR</td>\n",
       "      <td>CF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190925</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>38834200</td>\n",
       "      <td>-266465920</td>\n",
       "      <td>1051736020</td>\n",
       "      <td>191436960</td>\n",
       "      <td>102623950</td>\n",
       "      <td>0</td>\n",
       "      <td>-174435840</td>\n",
       "      <td>-604745400</td>\n",
       "      <td>733512300</td>\n",
       "      <td>106589200</td>\n",
       "      <td>-93800200</td>\n",
       "      <td>-42491700</td>\n",
       "      <td>1042793570</td>\n",
       "      <td>M</td>\n",
       "      <td>CF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190926</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>18057580</td>\n",
       "      <td>-248681300</td>\n",
       "      <td>-447420800</td>\n",
       "      <td>-133417200</td>\n",
       "      <td>25171960</td>\n",
       "      <td>0</td>\n",
       "      <td>-162065280</td>\n",
       "      <td>-640491620</td>\n",
       "      <td>209059720</td>\n",
       "      <td>234698400</td>\n",
       "      <td>-68429010</td>\n",
       "      <td>-105931360</td>\n",
       "      <td>-1319448910</td>\n",
       "      <td>JD</td>\n",
       "      <td>CF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190927</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-15130000</td>\n",
       "      <td>-249823700</td>\n",
       "      <td>-556281400</td>\n",
       "      <td>-111487200</td>\n",
       "      <td>-523773710</td>\n",
       "      <td>156995640</td>\n",
       "      <td>-145625350</td>\n",
       "      <td>-490085900</td>\n",
       "      <td>261324540</td>\n",
       "      <td>249855270</td>\n",
       "      <td>-73347260</td>\n",
       "      <td>-152318820</td>\n",
       "      <td>-1649697890</td>\n",
       "      <td>SR</td>\n",
       "      <td>M</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190930</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-23532700</td>\n",
       "      <td>-225974880</td>\n",
       "      <td>0</td>\n",
       "      <td>86449400</td>\n",
       "      <td>-484581230</td>\n",
       "      <td>151850900</td>\n",
       "      <td>-132267850</td>\n",
       "      <td>-892946505</td>\n",
       "      <td>-22825000</td>\n",
       "      <td>168860540</td>\n",
       "      <td>-58397040</td>\n",
       "      <td>-117575280</td>\n",
       "      <td>-1550939645</td>\n",
       "      <td>JD</td>\n",
       "      <td>CF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191008</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-36320400</td>\n",
       "      <td>-247768470</td>\n",
       "      <td>202964700</td>\n",
       "      <td>41253300</td>\n",
       "      <td>-607027140</td>\n",
       "      <td>154900270</td>\n",
       "      <td>-176945760</td>\n",
       "      <td>-997009575</td>\n",
       "      <td>46439800</td>\n",
       "      <td>182916160</td>\n",
       "      <td>-53270320</td>\n",
       "      <td>66726660</td>\n",
       "      <td>-1423140775</td>\n",
       "      <td>M</td>\n",
       "      <td>CF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191009</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-36193500</td>\n",
       "      <td>-269214400</td>\n",
       "      <td>433267380</td>\n",
       "      <td>150355600</td>\n",
       "      <td>-642128270</td>\n",
       "      <td>206059040</td>\n",
       "      <td>-158108240</td>\n",
       "      <td>-296862345</td>\n",
       "      <td>289595340</td>\n",
       "      <td>136506040</td>\n",
       "      <td>-45839390</td>\n",
       "      <td>24078600</td>\n",
       "      <td>-208484145</td>\n",
       "      <td>M</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191010</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-26545880</td>\n",
       "      <td>-273033100</td>\n",
       "      <td>500764160</td>\n",
       "      <td>126212800</td>\n",
       "      <td>-706012830</td>\n",
       "      <td>213666720</td>\n",
       "      <td>-148019280</td>\n",
       "      <td>-378837095</td>\n",
       "      <td>177076200</td>\n",
       "      <td>202615220</td>\n",
       "      <td>-58997760</td>\n",
       "      <td>32652900</td>\n",
       "      <td>-338457945</td>\n",
       "      <td>M</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191011</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-26730440</td>\n",
       "      <td>-291823740</td>\n",
       "      <td>594742500</td>\n",
       "      <td>180531780</td>\n",
       "      <td>-692274900</td>\n",
       "      <td>228931780</td>\n",
       "      <td>-144491000</td>\n",
       "      <td>-443261875</td>\n",
       "      <td>-74299200</td>\n",
       "      <td>156777250</td>\n",
       "      <td>-39656960</td>\n",
       "      <td>3252520</td>\n",
       "      <td>-548302285</td>\n",
       "      <td>M</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191014</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-4120970</td>\n",
       "      <td>-293777400</td>\n",
       "      <td>637119520</td>\n",
       "      <td>170027780</td>\n",
       "      <td>-662586060</td>\n",
       "      <td>189864600</td>\n",
       "      <td>-164284680</td>\n",
       "      <td>-24534980</td>\n",
       "      <td>174692700</td>\n",
       "      <td>32339000</td>\n",
       "      <td>-69233590</td>\n",
       "      <td>92509560</td>\n",
       "      <td>78015480</td>\n",
       "      <td>M</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191015</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-36968880</td>\n",
       "      <td>-308227500</td>\n",
       "      <td>630791100</td>\n",
       "      <td>122295150</td>\n",
       "      <td>-560225870</td>\n",
       "      <td>191402640</td>\n",
       "      <td>-117985280</td>\n",
       "      <td>42479760</td>\n",
       "      <td>120605800</td>\n",
       "      <td>14341880</td>\n",
       "      <td>-59351010</td>\n",
       "      <td>31436400</td>\n",
       "      <td>70594190</td>\n",
       "      <td>M</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191016</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-20657360</td>\n",
       "      <td>51074660</td>\n",
       "      <td>527519000</td>\n",
       "      <td>172016100</td>\n",
       "      <td>-566691120</td>\n",
       "      <td>271036780</td>\n",
       "      <td>-128266800</td>\n",
       "      <td>-205793545</td>\n",
       "      <td>-360660510</td>\n",
       "      <td>141109160</td>\n",
       "      <td>-40750920</td>\n",
       "      <td>47866680</td>\n",
       "      <td>-112197875</td>\n",
       "      <td>M</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191017</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-33957560</td>\n",
       "      <td>52954200</td>\n",
       "      <td>1322569350</td>\n",
       "      <td>135825800</td>\n",
       "      <td>-493990200</td>\n",
       "      <td>262045750</td>\n",
       "      <td>-140392360</td>\n",
       "      <td>-12911815</td>\n",
       "      <td>172723220</td>\n",
       "      <td>0</td>\n",
       "      <td>-47564370</td>\n",
       "      <td>10007090</td>\n",
       "      <td>1227309105</td>\n",
       "      <td>M</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191018</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-10344000</td>\n",
       "      <td>56403360</td>\n",
       "      <td>715461600</td>\n",
       "      <td>134866200</td>\n",
       "      <td>-458662050</td>\n",
       "      <td>237831930</td>\n",
       "      <td>-128719360</td>\n",
       "      <td>-197918940</td>\n",
       "      <td>18833430</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>51329120</td>\n",
       "      <td>419081290</td>\n",
       "      <td>M</td>\n",
       "      <td>Y</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191021</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>79027020</td>\n",
       "      <td>-31062000</td>\n",
       "      <td>2053650960</td>\n",
       "      <td>283123200</td>\n",
       "      <td>409866770</td>\n",
       "      <td>272069400</td>\n",
       "      <td>-123541560</td>\n",
       "      <td>-181981800</td>\n",
       "      <td>217608480</td>\n",
       "      <td>55982000</td>\n",
       "      <td>-37460880</td>\n",
       "      <td>69455880</td>\n",
       "      <td>3066737470</td>\n",
       "      <td>M</td>\n",
       "      <td>CF</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191022</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>4864500</td>\n",
       "      <td>20118360</td>\n",
       "      <td>1655138430</td>\n",
       "      <td>218971200</td>\n",
       "      <td>350486620</td>\n",
       "      <td>328186430</td>\n",
       "      <td>-124159490</td>\n",
       "      <td>25522035</td>\n",
       "      <td>-457020580</td>\n",
       "      <td>-19917600</td>\n",
       "      <td>0</td>\n",
       "      <td>244874560</td>\n",
       "      <td>2247064465</td>\n",
       "      <td>M</td>\n",
       "      <td>SR</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191023</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-20044800</td>\n",
       "      <td>-44928100</td>\n",
       "      <td>982043600</td>\n",
       "      <td>180110580</td>\n",
       "      <td>440942280</td>\n",
       "      <td>318997720</td>\n",
       "      <td>-125451460</td>\n",
       "      <td>69537650</td>\n",
       "      <td>42782680</td>\n",
       "      <td>-16983450</td>\n",
       "      <td>0</td>\n",
       "      <td>61005720</td>\n",
       "      <td>1888012420</td>\n",
       "      <td>M</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191024</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-58104960</td>\n",
       "      <td>-72964000</td>\n",
       "      <td>1879164800</td>\n",
       "      <td>160645120</td>\n",
       "      <td>1079814880</td>\n",
       "      <td>399839250</td>\n",
       "      <td>-105978960</td>\n",
       "      <td>124534270</td>\n",
       "      <td>472223220</td>\n",
       "      <td>31368530</td>\n",
       "      <td>-58808430</td>\n",
       "      <td>110543160</td>\n",
       "      <td>3962276880</td>\n",
       "      <td>M</td>\n",
       "      <td>OI</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety                A          C           M         RM           Y  \\\n",
       "date     会员简称                                                            \n",
       "20190920 海通期货  111016320 -375515400   358513250          0   236490480   \n",
       "20190923 海通期货  120200800 -382436180   119658000   25502750   205590900   \n",
       "20190924 海通期货   30263970 -312366960   244772580  139541560    47920000   \n",
       "20190925 海通期货   38834200 -266465920  1051736020  191436960   102623950   \n",
       "20190926 海通期货   18057580 -248681300  -447420800 -133417200    25171960   \n",
       "20190927 海通期货  -15130000 -249823700  -556281400 -111487200  -523773710   \n",
       "20190930 海通期货  -23532700 -225974880           0   86449400  -484581230   \n",
       "20191008 海通期货  -36320400 -247768470   202964700   41253300  -607027140   \n",
       "20191009 海通期货  -36193500 -269214400   433267380  150355600  -642128270   \n",
       "20191010 海通期货  -26545880 -273033100   500764160  126212800  -706012830   \n",
       "20191011 海通期货  -26730440 -291823740   594742500  180531780  -692274900   \n",
       "20191014 海通期货   -4120970 -293777400   637119520  170027780  -662586060   \n",
       "20191015 海通期货  -36968880 -308227500   630791100  122295150  -560225870   \n",
       "20191016 海通期货  -20657360   51074660   527519000  172016100  -566691120   \n",
       "20191017 海通期货  -33957560   52954200  1322569350  135825800  -493990200   \n",
       "20191018 海通期货  -10344000   56403360   715461600  134866200  -458662050   \n",
       "20191021 海通期货   79027020  -31062000  2053650960  283123200   409866770   \n",
       "20191022 海通期货    4864500   20118360  1655138430  218971200   350486620   \n",
       "20191023 海通期货  -20044800  -44928100   982043600  180110580   440942280   \n",
       "20191024 海通期货  -58104960  -72964000  1879164800  160645120  1079814880   \n",
       "\n",
       "variety                P         OI         CF         SR         JD  \\\n",
       "date     会员简称                                                          \n",
       "20190920 海通期货  248209840 -167490600 -519732675  552991320  110193760   \n",
       "20190923 海通期货  288043350          0 -677341980          0  108248120   \n",
       "20190924 海通期货  231041130 -180223850 -688653315  596871800  121108320   \n",
       "20190925 海通期货          0 -174435840 -604745400  733512300  106589200   \n",
       "20190926 海通期货          0 -162065280 -640491620  209059720  234698400   \n",
       "20190927 海通期货  156995640 -145625350 -490085900  261324540  249855270   \n",
       "20190930 海通期货  151850900 -132267850 -892946505  -22825000  168860540   \n",
       "20191008 海通期货  154900270 -176945760 -997009575   46439800  182916160   \n",
       "20191009 海通期货  206059040 -158108240 -296862345  289595340  136506040   \n",
       "20191010 海通期货  213666720 -148019280 -378837095  177076200  202615220   \n",
       "20191011 海通期货  228931780 -144491000 -443261875  -74299200  156777250   \n",
       "20191014 海通期货  189864600 -164284680  -24534980  174692700   32339000   \n",
       "20191015 海通期货  191402640 -117985280   42479760  120605800   14341880   \n",
       "20191016 海通期货  271036780 -128266800 -205793545 -360660510  141109160   \n",
       "20191017 海通期货  262045750 -140392360  -12911815  172723220          0   \n",
       "20191018 海通期货  237831930 -128719360 -197918940   18833430          0   \n",
       "20191021 海通期货  272069400 -123541560 -181981800  217608480   55982000   \n",
       "20191022 海通期货  328186430 -124159490   25522035 -457020580  -19917600   \n",
       "20191023 海通期货  318997720 -125451460   69537650   42782680  -16983450   \n",
       "20191024 海通期货  399839250 -105978960  124534270  472223220   31368530   \n",
       "\n",
       "variety              CS         AP         农产品 max min  \n",
       "date     会员简称                                           \n",
       "20190920 海通期货 -50734500 -235818580   268123215  SR  CF  \n",
       "20190923 海通期货 -53424000 -215593660  -461551900   P  CF  \n",
       "20190924 海通期货 -85050740 -103459400    41765095  SR  CF  \n",
       "20190925 海通期货 -93800200  -42491700  1042793570   M  CF  \n",
       "20190926 海通期货 -68429010 -105931360 -1319448910  JD  CF  \n",
       "20190927 海通期货 -73347260 -152318820 -1649697890  SR   M  \n",
       "20190930 海通期货 -58397040 -117575280 -1550939645  JD  CF  \n",
       "20191008 海通期货 -53270320   66726660 -1423140775   M  CF  \n",
       "20191009 海通期货 -45839390   24078600  -208484145   M   Y  \n",
       "20191010 海通期货 -58997760   32652900  -338457945   M   Y  \n",
       "20191011 海通期货 -39656960    3252520  -548302285   M   Y  \n",
       "20191014 海通期货 -69233590   92509560    78015480   M   Y  \n",
       "20191015 海通期货 -59351010   31436400    70594190   M   Y  \n",
       "20191016 海通期货 -40750920   47866680  -112197875   M   Y  \n",
       "20191017 海通期货 -47564370   10007090  1227309105   M   Y  \n",
       "20191018 海通期货         0   51329120   419081290   M   Y  \n",
       "20191021 海通期货 -37460880   69455880  3066737470   M  CF  \n",
       "20191022 海通期货         0  244874560  2247064465   M  SR  \n",
       "20191023 海通期货         0   61005720  1888012420   M  OI  \n",
       "20191024 海通期货 -58808430  110543160  3962276880   M  OI  "
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "农产品=sz.copy()\n",
    "农产品=农产品[['A','C','M','RM','Y','P','OI','CF','SR','JD','CS','AP','农产品']]\n",
    "农产品['max']=农产品[['A','C','M','RM','Y','P','OI','CF','SR','JD','CS','AP']].idxmax(axis=1) \n",
    "农产品['min']=农产品[['A','C','M','RM','Y','P','OI','CF','SR','JD','CS','AP']].idxmin(axis=1)\n",
    "农产品['20190920':]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>variety</th>\n",
       "      <th>商品板块</th>\n",
       "      <th>工业品</th>\n",
       "      <th>化工板块</th>\n",
       "      <th>黑色板块</th>\n",
       "      <th>有色板块</th>\n",
       "      <th>农产品</th>\n",
       "      <th>油脂板块</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th>会员简称</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20190920</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-3367909283</td>\n",
       "      <td>-2090441051</td>\n",
       "      <td>-731668845</td>\n",
       "      <td>-1215061600</td>\n",
       "      <td>98839624</td>\n",
       "      <td>268123215</td>\n",
       "      <td>317209720</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190923</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>902773365</td>\n",
       "      <td>-243088285</td>\n",
       "      <td>472287170</td>\n",
       "      <td>-477243880</td>\n",
       "      <td>-27667295</td>\n",
       "      <td>-461551900</td>\n",
       "      <td>493634250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190924</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-3829352983</td>\n",
       "      <td>-2584954486</td>\n",
       "      <td>-329268000</td>\n",
       "      <td>-1722998740</td>\n",
       "      <td>-46319066</td>\n",
       "      <td>41765095</td>\n",
       "      <td>98737280</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190925</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-1780657511</td>\n",
       "      <td>-1296392817</td>\n",
       "      <td>562774890</td>\n",
       "      <td>-713239850</td>\n",
       "      <td>-697478577</td>\n",
       "      <td>1042793570</td>\n",
       "      <td>-71811890</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190926</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-14986909680</td>\n",
       "      <td>-3678402103</td>\n",
       "      <td>-374837920</td>\n",
       "      <td>-2018585660</td>\n",
       "      <td>-1113108543</td>\n",
       "      <td>-1319448910</td>\n",
       "      <td>-136893320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190927</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-11863777349</td>\n",
       "      <td>-2225288250</td>\n",
       "      <td>-162181080</td>\n",
       "      <td>-1487899780</td>\n",
       "      <td>-243479330</td>\n",
       "      <td>-1649697890</td>\n",
       "      <td>-512403420</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20190930</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-13871758457</td>\n",
       "      <td>-2878440759</td>\n",
       "      <td>-216376170</td>\n",
       "      <td>-2199253000</td>\n",
       "      <td>-170578779</td>\n",
       "      <td>-1550939645</td>\n",
       "      <td>-464998180</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191008</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-12392693139</td>\n",
       "      <td>-2085598610</td>\n",
       "      <td>130202300</td>\n",
       "      <td>-2156280220</td>\n",
       "      <td>208514485</td>\n",
       "      <td>-1423140775</td>\n",
       "      <td>-629072630</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191009</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-13120403777</td>\n",
       "      <td>-3427403563</td>\n",
       "      <td>360220645</td>\n",
       "      <td>-3304434270</td>\n",
       "      <td>-123311868</td>\n",
       "      <td>-208484145</td>\n",
       "      <td>-594177470</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191010</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-14316810050</td>\n",
       "      <td>-3718143650</td>\n",
       "      <td>-620586410</td>\n",
       "      <td>-2453457020</td>\n",
       "      <td>-7781040</td>\n",
       "      <td>-338457945</td>\n",
       "      <td>-640365390</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191011</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-12907616577</td>\n",
       "      <td>-3209554979</td>\n",
       "      <td>-1159806660</td>\n",
       "      <td>-2191211710</td>\n",
       "      <td>746456431</td>\n",
       "      <td>-548302285</td>\n",
       "      <td>-607834120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191014</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-9968036048</td>\n",
       "      <td>-3103442206</td>\n",
       "      <td>-345362285</td>\n",
       "      <td>-2570838720</td>\n",
       "      <td>579208584</td>\n",
       "      <td>78015480</td>\n",
       "      <td>-637006140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191015</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-11249415180</td>\n",
       "      <td>-2698891850</td>\n",
       "      <td>-1145657960</td>\n",
       "      <td>-2232831720</td>\n",
       "      <td>1218828255</td>\n",
       "      <td>70594190</td>\n",
       "      <td>-486808510</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191016</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-16452210831</td>\n",
       "      <td>-4353627145</td>\n",
       "      <td>-1245406220</td>\n",
       "      <td>-3594121010</td>\n",
       "      <td>1169276755</td>\n",
       "      <td>-112197875</td>\n",
       "      <td>-423921140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191017</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-11449710501</td>\n",
       "      <td>-4195548682</td>\n",
       "      <td>-620964380</td>\n",
       "      <td>-2940793070</td>\n",
       "      <td>13679578</td>\n",
       "      <td>1227309105</td>\n",
       "      <td>-372336810</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191018</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-13522505129</td>\n",
       "      <td>-3842141973</td>\n",
       "      <td>-591316800</td>\n",
       "      <td>-2743888040</td>\n",
       "      <td>-234961868</td>\n",
       "      <td>419081290</td>\n",
       "      <td>-349549480</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191021</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-7767284078</td>\n",
       "      <td>-4192949941</td>\n",
       "      <td>-1497599915</td>\n",
       "      <td>-3462423890</td>\n",
       "      <td>748753039</td>\n",
       "      <td>3066737470</td>\n",
       "      <td>558394610</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191022</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-4448599039</td>\n",
       "      <td>-3111800133</td>\n",
       "      <td>-1031144370</td>\n",
       "      <td>-2791382050</td>\n",
       "      <td>735308687</td>\n",
       "      <td>2247064465</td>\n",
       "      <td>554513560</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191023</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>-4238682870</td>\n",
       "      <td>-2530019399</td>\n",
       "      <td>-1185070755</td>\n",
       "      <td>-2324842320</td>\n",
       "      <td>1129215936</td>\n",
       "      <td>1888012420</td>\n",
       "      <td>634488540</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20191024</th>\n",
       "      <th>海通期货</th>\n",
       "      <td>4504947387</td>\n",
       "      <td>-1117708206</td>\n",
       "      <td>-621138890</td>\n",
       "      <td>-2371140800</td>\n",
       "      <td>1820196354</td>\n",
       "      <td>3962276880</td>\n",
       "      <td>1373675170</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "variety               商品板块         工业品        化工板块        黑色板块        有色板块  \\\n",
       "date     会员简称                                                                \n",
       "20190920 海通期货  -3367909283 -2090441051  -731668845 -1215061600    98839624   \n",
       "20190923 海通期货    902773365  -243088285   472287170  -477243880   -27667295   \n",
       "20190924 海通期货  -3829352983 -2584954486  -329268000 -1722998740   -46319066   \n",
       "20190925 海通期货  -1780657511 -1296392817   562774890  -713239850  -697478577   \n",
       "20190926 海通期货 -14986909680 -3678402103  -374837920 -2018585660 -1113108543   \n",
       "20190927 海通期货 -11863777349 -2225288250  -162181080 -1487899780  -243479330   \n",
       "20190930 海通期货 -13871758457 -2878440759  -216376170 -2199253000  -170578779   \n",
       "20191008 海通期货 -12392693139 -2085598610   130202300 -2156280220   208514485   \n",
       "20191009 海通期货 -13120403777 -3427403563   360220645 -3304434270  -123311868   \n",
       "20191010 海通期货 -14316810050 -3718143650  -620586410 -2453457020    -7781040   \n",
       "20191011 海通期货 -12907616577 -3209554979 -1159806660 -2191211710   746456431   \n",
       "20191014 海通期货  -9968036048 -3103442206  -345362285 -2570838720   579208584   \n",
       "20191015 海通期货 -11249415180 -2698891850 -1145657960 -2232831720  1218828255   \n",
       "20191016 海通期货 -16452210831 -4353627145 -1245406220 -3594121010  1169276755   \n",
       "20191017 海通期货 -11449710501 -4195548682  -620964380 -2940793070    13679578   \n",
       "20191018 海通期货 -13522505129 -3842141973  -591316800 -2743888040  -234961868   \n",
       "20191021 海通期货  -7767284078 -4192949941 -1497599915 -3462423890   748753039   \n",
       "20191022 海通期货  -4448599039 -3111800133 -1031144370 -2791382050   735308687   \n",
       "20191023 海通期货  -4238682870 -2530019399 -1185070755 -2324842320  1129215936   \n",
       "20191024 海通期货   4504947387 -1117708206  -621138890 -2371140800  1820196354   \n",
       "\n",
       "variety               农产品        油脂板块  \n",
       "date     会员简称                          \n",
       "20190920 海通期货   268123215   317209720  \n",
       "20190923 海通期货  -461551900   493634250  \n",
       "20190924 海通期货    41765095    98737280  \n",
       "20190925 海通期货  1042793570   -71811890  \n",
       "20190926 海通期货 -1319448910  -136893320  \n",
       "20190927 海通期货 -1649697890  -512403420  \n",
       "20190930 海通期货 -1550939645  -464998180  \n",
       "20191008 海通期货 -1423140775  -629072630  \n",
       "20191009 海通期货  -208484145  -594177470  \n",
       "20191010 海通期货  -338457945  -640365390  \n",
       "20191011 海通期货  -548302285  -607834120  \n",
       "20191014 海通期货    78015480  -637006140  \n",
       "20191015 海通期货    70594190  -486808510  \n",
       "20191016 海通期货  -112197875  -423921140  \n",
       "20191017 海通期货  1227309105  -372336810  \n",
       "20191018 海通期货   419081290  -349549480  \n",
       "20191021 海通期货  3066737470   558394610  \n",
       "20191022 海通期货  2247064465   554513560  \n",
       "20191023 海通期货  1888012420   634488540  \n",
       "20191024 海通期货  3962276880  1373675170  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "板块=sz.copy()\n",
    "板块=板块[['商品板块','工业品','化工板块','黑色板块','有色板块','农产品','油脂板块']]\n",
    "板块['20190920':]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
